﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PageTitle" runat="server">
    <title>通讯录</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PageStyles" runat="server">
    <style type="text/css">
        div.avatar
        {
            float: left;
            width: 55px;
        }
        .mvcPager input[type="text"]
        {
            width: 20px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PageScripts" runat="server">
    <script type="text/javascript">
    //************* URL常量
    var URL_UPDATE_STAFFINFO = "";
    //************* 全局变量
    var g_Var = {
        
    };

    //************* 常量定义
    var StaticResource = {
};
//************* Accessor访问器


var EzAccessor = {};
function CreateAccessor() {
    if (ezmock.IS_MOCKED) {
        EzAccessor = CreateMockEzAccessor();

    } else {
        EzAccessor = CreateRealEzAccessor();
    }
}





function CreateMockEzAccessor() {
   
    //模拟实现服务器交互方法
    var mockEzAccessor = {
       

    };
    return mockEzAccessor;
}


function CreateRealEzAccessor() {
    //实现服务器交互方法
    var realEzAccessor = {
        "getUserId": function () {
            return <%= ViewData["userId"] %>;
        },
        "getDeptList": function(){
            return <%= ViewData["DeptList"]%>;
        }
    };

    return realEzAccessor;
}




//绑定部门列表
function bindDeptList (deptList){
    //手动加入所有人的超链接
    deptList.splice(0,0,{DeptName :'所有人'});

    //绑定部门的超链接
    for (var key in deptList) {
        var deptName = deptList[key].DeptName;
        var deptId = deptList[key].Id;
        var deptNameDom = '<a class="indent" onclick="bindUserStaffThisDept(\'{deptId}\')">{deptName}</a><br/>';
        deptNameDom = deptNameDom.replace("{deptId}", deptId)
                                 .replace("{deptName}", deptName);

        $('#cmbDeptList').append(deptNameDom);
    }
}


//获取选中部门的员工通讯录
function bindUserStaffThisDept(deptId){
    if(deptId == "undefined" || deptId == null)
    {
        window.location.href = "ContactBook";   
        return;
   }
   
    window.location.href = "ContactBook?deptId=" + deptId;   

}

function initPage() {
    EzTipsManager.addTipBox('#tip_remind', 'tipRemind');
    EzTipsManager.showTipBox('tipRemind');
    
    CreateAccessor();
    var userId = EzAccessor.getUserId();
    if(userId != null){
        $('#' + userId).css({
            'background-color':'#FFFF66',
            'border': '1px solid #ed4753'
        }); 
    } 

    var deptList = EzAccessor.getDeptList();
    bindDeptList(deptList);
}



function initPageEvent() {

}


$(function () {
    initPage();
    initPageEvent();
});

    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PageHead" runat="server">
    <%
        Html.RenderPartial("_sayHello"); %>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="PageContent" runat="server">
    <div id="page-head" class="page-head">
        <img src="../../Content/icons/contactBook.png" style="width: 48px; height: 48px;"
            alt="contactBook" />
        <span class="title">通讯录</span>
    </div>
    <div id="page-body">
        <div style="margin: 10px auto; text-align: left;">
            <% RenderPartialExtensions.RenderPartial(Html, "_staffList", ViewData["AllContactInfo"]); %>
        </div>
    </div>
    <div class="page-submit">
        <div id="pageCount">
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="PageShortcut" runat="server">
    <div id="shortcuts" class="box">
        <a id="btn-mycontactinfo"  style="width:100%;" href="/staff/mycontactInfo">我的联系方式</a>
        <script>
            $(function () {
                $("#btn-mycontactinfo").button({
                    icons: {
                        primary: "ui-icon-gear"
                    },
                    text: true
                });
            });
        </script>
    </div>
    <div id="tips" class="box">
    </div>
    <div class="clearfloat">
    </div>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="PageFoot" runat="server">
    <div id="tip_remind" style="display: none; min-height: 130px;">
        <h1>
            按部门过滤</h1>
        <div id="cmbDeptList">
        </div>
    </div>
</asp:Content>
